<#include "/common/head.html"/>
<script type="text/javascript">
jQuery(function($) {
} );
function optDetail(id){
	$.dialog("${baseUrl}/order/get?id="+id,"订单详情","1100px","500px");
}
function optPay(oid){
	$.post("${baseUrl}/order/edit",{state:"1",oid:oid},function(data){
		alertMsg(data.msg.msgText,data.msg.msgStatus);
		window.location.href="${baseUrl}/order/list?uid=${currentUser.username!}";
	});
}
function optCancel(oid){
	$.post("${baseUrl}/order/edit",{state:"3",oid:oid},function(data){
		$.confirm("确定取消订单？",function(){
			alertMsg(data.msg.msgText,data.msg.msgStatus);
			window.location.href="${baseUrl}/order/list?uid=${currentUser.username!}";
		});
	});
}
function optDel(oid){
	$.confirm("确定删除订单？",function(){
	$.post("${baseUrl}/order/remove",{oid:oid},function(data){
			alertMsg(data.msg.msgText,data.msg.msgStatus);
			window.location.href="${baseUrl}/order/list?uid=${currentUser.username!}";
		});
	});
}
function  optConfirmPay(oid,total){
	$.confirm("请确定已收到书籍,"+total+"元将自动打入卖家账户",function(){
		$.post("${baseUrl}/order/edit",{state:"4",oid:oid},function(data){
			alertMsg(data.msg.msgText,data.msg.msgStatus);
			window.location.href="${baseUrl}/order/list?uid=${currentUser.username!}";
		});
	});
}
</script>
<div class="home-page">
	<div class="content">
	<div class="container">
	<h3 class="header smaller lighter blue">我的订单</h3>										
<div class="row">
<div class="col-xs-12">
<div class="tab-content">
<table id="sample-table-1" class="table table-striped table-bordered table-hover" style="text-align: center;">
											<thead>
												<tr>
													<th class="center">
														<label class="position-relative">
															<input type="checkbox" class="ace" />
															<span class="lbl"></span>
														</label>
													</th>
													<th>订单号</th>
													<th>总价</th>
													<th class="hidden-480">下单时间</th>
													<th class="hidden-480">状态</th>

													<th>操作</th>
												</tr>
											</thead>

											<tbody>
											<#list orders.rows as order>
												<tr>
													<td class="center">
														<label class="position-relative">
															<input type="checkbox" class="ace"/>
															<span class="lbl"></span>
														</label>
													</td>

													<td>
														<a href="#none" onclick="optDetail('${order.oid!}')">${order.oid!}</a>
													</td>
													<td>${order.total!}</td>
													<td class="hidden-480">${order.date!}</td>

													<td class="hidden-480">
														<#if order.state=="0">
														<span class="label label-sm label-warning">待付款</span>
														</#if>
														<#if order.state=="1">
														<span class="label label-sm label-warning">订单待处理</span>
														</#if>
														<#if order.state=="2">
														<span class="label label-sm label-info">快递运输中</span>
														</#if>
														<#if order.state=="3">
														<span class="label label-sm label-danger">交易已关闭</span>
														</#if>
														<#if order.state=="4">
														<span class="label label-sm label-success">交易成功</span>
														</#if>
													</td>

													<td>
														<div class="hidden-sm hidden-xs btn-group">
														<#if order.state=="0">
																<button class="btn btn-xs btn-warning" title="付款" onclick="optPay('${order.oid!}')">
																<span class="label label-sm label-warning">付款&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
															</button>
														</#if>
														<#if order.state=="2">
																<button class="btn btn-xs btn-success" title="确认收货" onclick="optConfirmPay('${order.oid!}','${order.total!}')">
																<span class="label label-sm label-success">确认收货</span>
															</button>
														</#if>
														<#if order.state=="3" ||  order.state=="4">
																<button class="btn btn-xs btn-danger" title="删除订单" onclick="optDel('${order.oid!}')">
																<span class="label label-sm label-danger">删除订单</span>
															</button>
														</#if>
														<#if order.state =="1" || order.state=="0">
															<button class="btn btn-xs btn-danger" title="取消订单" onclick="optCancel('${order.oid!}')">
																<span class="label label-sm label-danger">取消订单</span>
															</button>
														</#if>
														</div>

														<div class="hidden-md hidden-lg">
															<div class="inline position-relative">
																<button class="btn btn-minier btn-primary dropdown-toggle" data-toggle="dropdown" data-position="auto">
																	<i class="ace-icon fa fa-cog icon-only bigger-110"></i>
																</button>

																<ul class="dropdown-menu dropdown-only-icon dropdown-yellow dropdown-menu-right dropdown-caret dropdown-close">
																	<li>
																		<a href="#" class="tooltip-info" data-rel="tooltip" title="View">
																			<span class="blue">
																				<i class="ace-icon fa fa-search-plus bigger-120"></i>
																			</span>
																		</a>
																	</li>

																	<li>
																		<a href="#" class="tooltip-success" data-rel="tooltip" title="Edit">
																			<span class="green">
																				<i class="ace-icon fa fa-pencil-square-o bigger-120"></i>
																			</span>
																		</a>
																	</li>

																	<li>
																		<a href="#" class="tooltip-error" data-rel="tooltip" title="Delete">
																			<span class="red">
																				<i class="ace-icon fa fa-trash-o bigger-120"></i>
																			</span>
																		</a>
																	</li>
																</ul>
															</div>
														</div>
													</td>
												</tr>
												</#list>													</tbody>
													</table>
												<ul class="pagination pull-right no-margin" style="margin-top: 0px;">
													<li class="prev <#if orders.page==1>disabled</#if>">
														<a href="#">
															<i class="ace-icon fa fa-angle-double-left"></i>
														</a>
													</li>

													<li class="active">
														<a href="#">${orders.page}</a>
													</li>
													<#if orders.total==2>	
													<li>
														<a href="#">${orders.page+1}</a>
													</li>
													</#if>
													<#if orders.total !=2 &&  orders.total !=1>	
													<li>
														<a href="#">${orders.page+2}</a>
													</li>
													</#if>
													<li class="next <#if orders.page==orders.total>disabled</#if>">
														<a href="#">
															<i class="ace-icon fa fa-angle-double-right"></i>
														</a>
													</li>
												</ul>
													</div>
													</div>
													</div>
													</div>
													</div>
<div style="bottom: 0px;position:fixed;">								
<#include "/common/foot.html"/>
</div>